import request from '@/utils/request'

// 获取房间列表
export function getRoomList(params) {
  return request({
    url: '/game/room/list',
    method: 'get',
    params
  })
}

// 创建房间
export function createRoom(data) {
  return request({
    url: '/game/room/create',
    method: 'post',
    data
  })
}

// 加入房间
export function joinRoom(roomId, password) {
  return request({
    url: '/game/room/join',
    method: 'post',
    data: { roomId, password }
  })
}

// 离开房间
export function leaveRoom(roomId) {
  return request({
    url: '/game/room/leave',
    method: 'post',
    data: { roomId }
  })
}

// 获取房间详情
export function getRoomDetail(roomId) {
  return request({
    url: '/game/room/detail',
    method: 'get',
    params: { roomId }
  })
}

// 准备/取消准备
export function toggleReady(roomId) {
  return request({
    url: '/game/room/ready',
    method: 'post',
    data: { roomId }
  })
}

// 开始游戏
export function startGame(roomId) {
  return request({
    url: '/game/start',
    method: 'post',
    data: { roomId }
  })
}

// 亮黑A
export function showBlackA(roomId, cardId) {
  return request({
    url: '/game/show-black-a',
    method: 'post',
    data: { roomId, cardId }
  })
}

// 反红A
export function showRedA(roomId, cardId) {
  return request({
    url: '/game/show-red-a',
    method: 'post',
    data: { roomId, cardId }
  })
}

// 出牌
export function playCards(roomId, cards) {
  return request({
    url: '/game/play',
    method: 'post',
    data: { roomId, cards }
  })
}

// 过牌
export function passCards(roomId) {
  return request({
    url: '/game/pass',
    method: 'post',
    data: { roomId }
  })
}

// 获取游戏状态
export function getGameStatus(roomId) {
  return request({
    url: '/game/status',
    method: 'get',
    params: { roomId }
  })
}
